#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Display Device Class
 *      Provides a class for manipulating display devices in the system.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
#include "AiObjectBase.h"

using namespace System;
using namespace Adaptive::Foundation;

namespace Adaptive
{
	namespace Win32
	{
		/// <summary>
		/// Provides a class for manipulating display devices in the system.
		/// </summary>
		public ref class DisplayDevice : public AiObjectBase
		{
		public:
			/*--------------------------------------------------------------------------------
			 * Public Event Definitions
			 *------------------------------------------------------------------------------*/
			#pragma region Public Event Definitions
			#pragma endregion

			/*--------------------------------------------------------------------------------
			 * Constructor / Dispose / Destructor Methods
			 *------------------------------------------------------------------------------*/
			#pragma region Constructor / Dispose / Destructor Methods
			/// <summary>
			/// Initializes a new instance of the class.
			/// </summary>
			/// <remarks>
			/// This is the default constructor.
			/// </remarks>
			DisplayDevice();
			/// <summary>
			/// Initializes a new instance of the class for the specified parameters.
			/// </summary>
			/// <param name="deviceName">The unique name associated with the device.</param>
			/// <param name="deviceId">The unique system identifier for the device.</param>
			/// <param name="displayName">The display name for the device.</param>
			/// <param name="deviceKey">The registry key for the device.</param>
			/// <param name="flags">The state flags associated with the device.</param>
			DisplayDevice(String^ deviceName, String^ deviceId, String^ displayName, String ^deviceKey, int flags);
			/// <summary>
			/// Class destructor.
			/// </summary>
			~DisplayDevice();
			#pragma endregion

			/*--------------------------------------------------------------------------------
			 * Public Properties
			 *------------------------------------------------------------------------------*/
			#pragma region Public Properties
			/// <summary>
			/// Gets a value indicating whether the display device is attached to the desktop.
			/// </summary>
			/// <value>
			/// <b>true</b> if the device is part of the desktop; otherwise, <b>false</b>.
			/// </value>
			property bool AttachedToDesktop { bool get(); }
			/// <summary>
			/// Gets a value indicating whether the display device is a mirroring device.
			/// </summary>
			/// <remarks>
			/// Represents a pseudo device used to mirror application drawing for remoting or other purposes. An invisible pseudo 
			/// monitor is associated with this device. For example, NetMeeting uses it. Note that GetSystemMetrics(SM_MONITORS) 
			/// only accounts for visible display monitors.
			/// </remarks>
			/// <value>
			/// <b>true</b> if the device is psuedo device for mirroring; otherwise, <b>false</b>.
			/// </value>
			property bool MirroringDriver { bool get(); }
			/// <summary>
			/// Gets a value indicating whether the display device has more display modes than its output devices support.
			/// </summary>
			/// <value>
			/// <b>true</b> if the device has more display modes than its output devices support; otherwise, <b>false</b>.
			/// </value>
			property bool ModesPruned { bool get(); }
			/// <summary>
			/// Gets a value indicating whether the display device is the primary display device.
			/// </summary>
			/// <value>
			/// <b>true</b> if the device is the primary display device; otherwise, <b>false</b>.
			/// </value>
			property bool Primary { bool get(); }
			/// <summary>
			/// Gets a value indicating whether the display device is removable.
			/// </summary>
			/// <value>
			/// <b>true</b> if the device is removable; otherwise, <b>false</b>.
			/// </value>
			property bool Removable { bool get(); }
			/// <summary>
			/// Gets a value indicating whether the display device is VGA compatible.
			/// </summary>
			/// <value>
			/// <b>true</b> if the device is VGA compatible; otherwise, <b>false</b>.
			/// </value>
			property bool VgaCompatible { bool get(); }
			/// <summary>
			/// Gets the name of the device.
			/// </summary>
			/// <value>
			/// The name of the the adapter device or the monitor device.
			/// </value>
			property String^ DeviceName { String^ get(); }
			/// <summary>
			/// Gets the unique identifier value of the device.
			/// </summary>
			/// <value>
			/// This is the plug-and-play ID value for the device.
			/// </value>
			property String^ DeviceID { String^ get(); }
			/// <summary>
			/// Gets the device context string.
			/// </summary>
			/// <value>
			/// A description of the display adapter or of the display monitor.
			/// </value>
			property String^ DeviceString { String^ get(); }
			/// <summary>
			/// Gets the device registry key.
			/// </summary>
			/// <value>
			/// May be reserved, or a registry key associated with the device.
			/// </value>
			property String^ DeviceKey { String^ get(); }
			/// <summary>
			/// Gets the device driver version.
			/// </summary>
			/// <value>
			/// A device driver version as an integer.
			/// </value>
			property int DriverVersion { int get(); }
			/// <summary>
			/// Gets the device technology value.
			/// </summary>
			/// <value>
			/// A device technology constant value.
			/// </value>
			property int Technology { int get(); }
			/// <summary>
			/// Gets the width of the physical screen.
			/// </summary>
			/// <value>
			/// The width of the screen, in millimeters.
			/// </value>
			property int HorizontalSize { int get(); }
			/// <summary>
			/// Gets the height of the physical screen.
			/// </summary>
			/// <value>
			/// The height of the screen, in millimeters.
			/// </value>
			property int VerticalSize { int get(); }
			/// <summary>
			/// Gets the width of the screen in pixels.
			/// </summary>
			/// <value>
			/// The width of the screen in pixels.
			/// </value>
			property int HorizontalResolution { int get(); }
			/// <summary>
			/// Gets the height of the screen in pixels.
			/// </summary>
			/// <value>
			/// The height of the screen in pixels.
			/// </value>
			property int VerticalResolution { int get(); }
			/// <summary>
			/// Gets the number of pixels per logical inch along the screen width.
			/// </summary>
			/// <remarks>
			/// In a system with multiple display monitors, this value is the same for all monitors.
			/// </remarks>
			/// <value>
			/// The number of pixels per inch along the width of the screen.
			/// </value>
			property int LogicalPixelsX { int get(); }
			/// <summary>
			/// Gets the number of pixels per logical inch along the screen height.
			/// </summary>
			/// <remarks>
			/// In a system with multiple display monitors, this value is the same for all monitors.
			/// </remarks>
			/// <value>
			/// The number of pixels per inch along the height of the screen.
			/// </value>
			property int LogicalPixelsY { int get(); }
			/// <summary>
			/// Gets the number of adjacent color bits for each pixel
			/// </summary>
			/// <value>
			/// The number of bits used to define each pixel.  This determines color-depth.
			/// </value>
			property int BitsPerPixel { int get(); }
			/// <summary>
			/// Gets the number of color planes.
			/// </summary>
			/// <value>
			/// The number of color planes.
			/// </value>
			property int PlaneCount { int get(); }
			/// <summary>
			/// Gets the number of entries in the device's color table.
			/// </summary>
			/// <remarks>
			/// This value is valid only if the device has a color depth of no more than 8 bits per pixel. 
			/// For devices with greater color depths,  1 is returned.
			/// </remarks>
			/// <value>
			/// The number of entries in the color table or 1.
			/// </value>
			property int ColorCount { int get(); }
			/// <summary>
			/// Gets the number of device-specific fonts.
			/// </summary>
			/// <value>
			/// The number of device-specific fonts.
			/// </value>
			property int FontCount { int get(); }
			/// <summary>
			/// Gets the number of device-specific pens.
			/// </summary>
			/// <value>
			/// The number of device-specific pens.
			/// </value>
			property int PenCount { int get(); }
			/// <summary>
			/// Gets the number of device-specific brushes.
			/// </summary>
			/// <value>
			/// The number of device-specific brushes.
			/// </value>
			property int BrushCount { int get(); }
			/// <summary>
			/// Gets the relative width of a device pixel used for line drawing.
			/// </summary>
			/// <value>
			/// The relative width of a pixel alogn the X co-ordinate.
			/// </value>
			property int AspectX { int get(); }
			/// <summary>
			/// Gets the relative height of a device pixel used for line drawing.
			/// </summary>
			/// <value>
			/// The relative height of a pixel alogn the Y co-ordinate.
			/// </value>
			property int AspectY { int get(); }
			/// <summary>
			/// Gets the diagonal width of the device pixel used for line drawing.
			/// </summary>
			/// <value>
			/// The size of the pixel's diagonal diameter.
			/// </value>
			property int AspectXY { int get(); }
			/// <summary>
			/// Gets the current vertical refresh rate of the device, in cycles per second (Hz). 
			/// </summary>
			/// <remarks>
			/// A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. 
			/// This default rate is typically set by switches on a display card or computer motherboard, or by 
			/// a configuration program that does not use display functions such as <b>ChangeDisplaySettings</b>.
			/// </remarks>
			/// <value>
			/// The vertical refresh rate in cycles per second (Hz), or a 0 or 1 value.
			/// </value>
			property int VerticalRefreshRate { int get(); }

			#pragma endregion
 
			/*--------------------------------------------------------------------------------
	         * Public Methods / Functions
		     *------------------------------------------------------------------------------*/
			#pragma region Public Methods / Functions
			/// <summary>
			/// Gets the list of display devices on the system.
			/// </summary>
			/// <returns>
			/// An array of <see cref="DisplayDevice"/> instances representing the display devices
			/// defined on the system.
			/// </returns>
			static array<DisplayDevice^>^ GetDisplayDeviceList();
			/// <summary>
			/// Modifies the screen resolution to the desired widht and height.
			/// </summary>
			/// <param name="width">The desired width of the display device, in pixels.</param>
			/// <param name="height">The desired height of the display device, in pixels.</param>
			/// <returns>
			/// <b>true</b> if the operation was completed successfully; otherwise, <b>false</b>.
			/// </returns>
			bool ChangeScreenResolution(int width, int height);
			/// <summary>
			/// Modifies the screen resolution to the desired widht and height.
			/// </summary>
			/// <param name="width">The desired width of the display device, in pixels.</param>
			/// <param name="height">The desired height of the display device, in pixels.</param>
			/// <param name="colorDepth">A <see cref="ColorDepth"/> enumerated value indicating the desired color depth.</param>
			/// <returns>
			/// <b>true</b> if the operation was completed successfully; otherwise, <b>false</b>.
			/// </returns>
			bool ChangeScreenResolutionAndColorDepth(int width, int height, ColorDepth colorDepth);
			/// <summary>
			/// Changes the display mode to full screen.
			/// </summary>
			/// <returns>
			/// <b>true</b> if the operation was completed successfully; otherwise, <b>false</b>.
			/// </returns>
			bool GotoFullScreen();
			/// <summary>
			/// Changes the display mode to normal windowed mode.
			/// </summary>
			/// <returns>
			/// <b>true</b> if the operation was completed successfully; otherwise, <b>false</b>.
			/// </returns>
			bool GotoWindowedMode();
			/// <summary>
			/// Refreshes the information content for the display device instance.
			/// </summary>
			void Refresh();
	        #pragma endregion

		private:
			/*--------------------------------------------------------------------------------
			 * Private Member Declarations
			 *------------------------------------------------------------------------------*/
			#pragma region Private Member Declarations

			String^ _deviceName;
			String^ _deviceString;
			String^ _deviceId;
			String^ _deviceKey;
			int		_stateFlags;
			int		_driverVersion;
			int		_technology;
			int		_horizontalSize;
			int		_verticalSize;
			int		_horizontalResolution;
			int		_verticalResolution;
			int		_logicalPixelsX;
			int		_logicalPixelsY;
			int		_bitsPerPixel;
			int		_planeCount;
			int		_colorCount;
			int		_fontCount;
			int		_penCount;
			int		_brushCount;
			int		_aspectX;
			int		_aspectXY;
			int		_aspectY;
			int		_verticalRefreshRate;

			void	LoadInternalInformation();
			#pragma endregion

		};
	}
}